<?php namespace App\Infra\Admin;

use App\Utils\ModelSDK\ModelOperator;
use App\Models\User;
use App\Models\Role;

class UserManage{

	use ModelOperator;

	public function createUser($data){
		$data['password'] = bcrypt($data['password']);

		$this->create(User::class,$data);
	}

	public function deleteUser($data){
		$id = $data['id'];

		$user = User::find($id);

		$user->delete();

		return $user;
	}

	public function updatePassword($id,$data){
		
		$this->update(User::class,$id,$data);
	}

	public function updateUserInfo($id,$data){

		$user = User::find($id);

		$this->update(User::class,$id,$data);

		return $user;
	}

	public function getUsers(){
		return User::all();
	}

	public function getRoles(){
		return Role::all();
	}
}